package com.suray.wcs.service.pojo.rgv.rgv.protocol.message;

import com.suray.wcs.service.pojo.Rgv;
import com.suray.basic.wcs.utils.typedef.Bit;
import com.suray.basic.wcs.utils.typedef.Byte;
import com.suray.basic.wcs.utils.typedef.Word;
import com.suray.wcs.service.pojo.rgv.rgv.protocol.base.RgvSendMessage;
import com.suray.wcs.service.pojo.rgv.rgv.protocol.util.RgvMessageType;

public class RgvSendClearOrderMessage extends RgvSendMessage {
    public RgvSendClearOrderMessage(Rgv rgv) {
        super(rgv, "清除Scada里程数据");

        baseDatas.add(new Word("firstFrame", "报文头帧：02 fd"));
        baseDatas.add(new Byte("deviceId", "小车对应设备号"));
        baseDatas.add(new Byte("life", "心跳、指令、任务共用，没发一帧数据+1,0-255循环，res收到后原数据返回"));
        baseDatas.add(new Bit(4,"frameType", "报文类型"));
        baseDatas.add(new Bit(4,"version", "版本号"));
        baseDatas.add(new Word("msgLen", "长度"));
        baseDatas.add(new Word("CRC16", "CRC检验位"));
        baseDatas.add(new Word("endFrame", "报文尾帧：03 fc"));
        setDefaultValue();
        setValue("frameType", RgvMessageType.RGV_CLEAR_ORDER_MESSAGE.getValue());
    }

    @Override
    protected void setCrc(int crc) {
        setValue("CRC16", crc);
    }

    @Override
    protected void setLength(int length) {
        setValue("msgLen", length);
    }

    @Override
    public Integer getMessageLife() {
        return getValue("life");
    }

    @Override
    public Integer getMessageType() {
        return getValue("frameType");
    }

}
